﻿using System;
using System.Text;

using BizElements.Core.ProviderComponents;

namespace BizElements.Core.Oracle
{
    sealed class OracleColumnRenderer : IColumnRenderer
    {
        public void RenderColumnName(IDbColumn column, StringBuilder output)
        {
            // Special characters are not supported in column names for Oracle.
            output.Append(column.ColumnName);
        }

        public void RenderAlias(IDbColumn column, StringBuilder output)
        {
            if (OracleTableRenderer.IsNonquotedIdentifier(column.Alias))
            {
                // Don't quote alfanumeric identifiers because in that case Oracle is case sensitive
                output.Append(column.Alias);
            }
            else
            {
                // Special characters must be enclosed in quotes.
                output.Append("\"");
                output.Append(column.Alias);
                output.Append("\"");
            }
        }
    }
}